import {createRouter, createWebHashHistory} from 'vue-router';

// // 路由列表
// const pages = import.meta.glob('../views/**/page.js', {
//     eager: true,
//     import: 'default'
// });
// const pageComps = import.meta.glob('../views/**/index.vue')
// const router = Object.entries(pages).map(([path, meta]) => {
//     const pageJSPath = path;
//     path = path.replace("../views", '').replace("/page.js", "")
//     path = path || '/'
//     const name = path.split('/').filter(Boolean).join('-') || 'index';
//     const compPath = pageJSPath.replace('page.js', 'index.vue')
//
//     let data = {}
//
//     // if(meta.isChild == 1){
//     data = {
//         path: path,
//         name: name,
//         component: pageComps[compPath],
//         children: [],
//         meta
//         // }
//     }
//
//     console.log(data)
//
//     //
//     // if(meta.isChild == 2){
//     //     data.children = [
//     //         {
//     //             path: path,
//     //             name: name,
//     //             component: pageComps[compPath],
//     //             meta
//     //         }
//     //     ]
//     // }
//
//     return data
// })
const routes = [

    {
        // 登录
        path: '/login',
        name: 'login',
        component: () => import( '../views/login.vue'),

    },
    {
        // 首页
        path: '/index',
        name: 'index',
        component: () => import( '../views/home/index.vue'),

    },
    {
        //项目列表
        path: '/cases',
        name: 'cases',
        component: () => import( '../views/home/cases.vue'),

    }, {
        //项目详细
        path: '/casesDetail',
        name: 'casesDetail',
        component: () => import( '../views/home/casesDetail.vue'),

    }, {
        //消息中心
        path: '/message',
        name: 'message',
        component: () => import( '../views/home/message.vue'),

    }, {
        //我的页面
        path: '/my',
        name: 'my',
        redirect: '/myindex',
        component: () => import( '../views/my/my.vue'),
        children: [
            {
                //个人主页
                path: '/myindex',
                name: 'myindex',
                component: () => import( '../views/my/myindex.vue'),
            },
            {
                //我的投标
                path: '/mybid',
                name: 'mybid',
                component: () => import( '../views/my/mybid.vue'),
            },
            {
                //浏览记录
                path: '/mylog',
                name: 'mylog',
                component: () => import( '../views/my/mylog.vue'),
            },
            {
                //我的收藏
                path: '/mycollect',
                name: 'mycollect',
                component: () => import( '../views/my/mycollect.vue'),
            },
            {
                //  账户设置
                path: '/myaccount',
                name: 'myaccount',
                component: () => import( '../views/my/myaccount.vue'),
            }
        ]

    },{
        //消息中心
        path: '/',
        name: 'admin',
        redirect: '/bidadd',
        component: () => import( '../views/admin/admin.vue'),
        children: [
            {
                //首页
                path: '/adminindex',
                name: 'adminindex',
                component: () => import( '../views/admin/adminindex.vue'),
            }, {
                // 招标管理
                path: '/adminbid',
                name: 'adminbid',
                component: () => import( '../views/admin/adminbid.vue'),
            }, {
                // 招标管理
                path: '/bidadd',
                name: 'bidadd',
                component: () => import( '../views/admin/bidadd.vue'),
            },
        ]

    },

]
// console.log(routes)

// 导出路由
export default createRouter({
    history: createWebHashHistory(),
    routes: routes
})
